#include <AST/expr/literal/FloatAST.hpp>
#include <global.hpp>
#include <llvm/IR/DerivedTypes.h>

Float::Float(double val) : val(val) {
    // TODO
    cachedValue = llvm::ConstantFP::get(getType(), APFloat(val));
}

llvm::Type *Float::getType() {
    return BasicType::FloatTy;
}

llvm::Constant *Float::codegen() {
    return static_cast<Constant *>(cachedValue);
}

llvm::Value *Float::getDefault() {
    return llvm::ConstantFP::get(BasicType::FloatTy, APFloat(0.0f));
}
